<template>
  <div class="category-page">
    <div class="page-header">
      <h1>{{ route.query.name }}</h1>
    </div>

    <ProductList ref="ProductListRef" :show-filters="true" />
  </div>
</template>

<script setup>
import {onMounted, ref, watch} from 'vue'
import { useRoute } from 'vue-router'
import ProductList from '../../components/ProductList.vue'
const route = useRoute()

const ProductListRef = ref(null)

watch(
  () => route.query,
  (newPath) => {
    ProductListRef.value.initData()
  },{
    deep: true
  }
);

onMounted(() => {
  ProductListRef.value.initData()
})
</script>

<style lang="scss" scoped>
.category-page {
  padding: 20px;

  @media (max-width: 768px) {
    padding: 0;  // 移动端移除外边距
  }

  .page-header {
    margin-bottom: 24px;

    h1 {
      font-size: 28px;
      font-weight: bold;
      color: #0F1111;
    }
  }
}
</style>
